import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';

class Router extends Component {
	componentDidMount() {
		document.title = 'justdodo';
	}
	render() {
		const { routes } = this.props;
		return (
			<HashRouter>
				<Switch>
					{routes.map(item => (
						<Route {...item} key={item.path} />
					))}
					<Redirect to={routes[0].path} />
				</Switch>
			</HashRouter>
		);
	}
}
Router.propTypes = {
	routes: PropTypes.array
};

export default Router;